<?php
    /// set identities
    $sql = sprintf("SELECT * FROM `People` p WHERE p.`id` = '%s' ", 
            $_SESSION['lid']);
    //print($sql."<BR>\n");
    $res = mysql_query($sql) or die(mysql_error());
    $row =  mysql_fetch_assoc($res) or die(mysql_error());
    $_SESSION['linfo'] = $row ; // logged in person - cannot be changed
    
    // $_SESSION['pinfo'] is the 'current' identity, admin may choose it
    if (AmIAdmin()) unset($_SESSION['pinfo'] ); // none means all, admin may masquarady as anybody
    else {
        $_SESSION['pinfo'] = $row ; // non-admin has fixed identity
        $_SESSION['pinfo']['granty'] = SQLGrantyPerson($row['id']); // add list af all my projects 
    }
    mysql_free_result($res);
    
    
    
   // fetch ALL PEOPLE details
    $sql = sprintf("SELECT * FROM `People` WHERE `:active`=1 ORDER BY `:schedule-alias`");
    $res = mysql_query($sql) or die(mysql_error());
    $_SESSION['Global']['People'] = array();
    while ($row = mysql_fetch_assoc($res)){
            $_SESSION['Global']['People'][$row['id']]=$row;
        }
    mysql_free_result($res);
   // fetch ALL grants
    $_SESSION['Global']['Granty'] =  SQLGrantyPerson();
    
    
    
    
    /*
    $sql = sprintf( "SELECT `projects`.* FROM `PeopleInProjects`, `projects`"
            ." WHERE `PeopleInProjects`.person = '%d'", 
            $_SESSION['pinfo']['id']);
    $res = mysql_query($sql) or die(mysql_error());

    $_SESSION['granty']=array();
    while ($row = mysql_fetch_assoc($res)) { 
        $_SESSION['granty']= $row;
    }
    mysql_free_result($res);
*/
    
    SetVisibleInterval(date('n'), date('Y'));
   $_SESSION['view']['highlight_id']=0;

?>
